package com.msv.listener;

import com.msv.model.User;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

public class MyApplicationListener implements ApplicationListener<ContextRefreshedEvent>  {
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if(contextRefreshedEvent.getApplicationContext().getParent()==null){
           User user= (User) contextRefreshedEvent.getApplicationContext().getBean("user");
            System.out.println("用户名称："+user.getName());
        }
        System.out.println("contextRefreshedEvent");
    }

}
